package com.qsxc.system.exception;

import com.qsxc.enums.http.CustomHttpStatus;
import lombok.extern.slf4j.Slf4j;

/**
 * @author
 * @desc 自定义异常
 */
@Slf4j
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private String msg;
    private int code = 0;

    public CustomException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public CustomException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public CustomException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }

    public CustomException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }

    public CustomException(CustomHttpStatus httpStatus) {
        super(httpStatus.getMsg());
        this.code = httpStatus.getValue();
    }

    public CustomException(CustomHttpStatus httpStatus, String msg) {
        super(msg);
        this.code = httpStatus.getValue();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public void printStackTrace() {
        // 不打印自定义异常日志
    }
}
